<?php

namespace addons\sum\controller\store;

use addons\sum\controller\Common;
use addons\sum\service\store\Store as StroeService;
use app\admin\model\User;

class Apply extends Common
{

    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    // 发起申请请求
    public function apply()
    {
        $user = auth_user();
        $params = $this->request->param();
        $agent_id=$params['agent_id']??0;
        if($agent_id>0){
            $agent_user=User::where('id',$agent_id)->where('agent_status',2)->find();
            if(!$agent_user){
                $this->error('代理信息获取失败');
            }
        }
        $this->svalidate($params, ".apply");
        $store_service=new StroeService($user);
        $res=$store_service->apply($params);
        $this->success('申请成功');
    }
}
